package com.example.project.enums;

/**
 * 问题关联类型枚举
 * 
 * @author ruoyi
 * @date 2025-11-25
 */
public enum IssueRelationType {
    
    RELATES("relates", "关联到"),
    DUPLICATES("duplicates", "重复"),
    DUPLICATED("duplicated", "与其重复"),
    BLOCKS("blocks", "阻挡"),
    BLOCKED("blocked", "被阻挡"),
    PRECEDES("precedes", "优先于"),
    FOLLOWS("follows", "跟随于"),
    COPIED_TO("copied_to", "复制到"),
    COPIED_FROM("copied_from", "复制于");
    
    private final String code;
    private final String description;
    
    IssueRelationType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据code获取枚举
     * 
     * @param code 代码
     * @return 枚举
     */
    public static IssueRelationType getByCode(String code) {
        for (IssueRelationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return null;
    }
    
    /**
     * 根据code获取描述
     * 
     * @param code 代码
     * @return 描述
     */
    public static String getDescriptionByCode(String code) {
        IssueRelationType type = getByCode(code);
        return type != null ? type.getDescription() : null;
    }
}